package com.usian.controller;

import com.usian.pojo.Users;
import com.usian.service.UserService;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("user/{id}")
    public Users getUser(@PathVariable Integer id){
        return userService.getUser(id);
    }

    @RequestMapping("findAll")
    public List<Users> findAll(){
        return userService.findAll();
    }

    @RequestMapping("findByname/{nam}")
    public String findByname(@PathVariable String nam){
        return "findByname--"+nam;
    }
    @RequestMapping("findBynamea")
    public String findBynamea(@PathVariable String nam){
        return "findByname--"+nam;
    }


    @RequestMapping("findById")
    public String findById(@RequestParam Integer id){
        return "findById"+id;
    }



    @RequestMapping("findBynameandid/{nam}/{id}")
    public String findBynameandid(@PathVariable String nam,@PathVariable Integer id){
        return "findByname--"+nam+"--"+id;
    }
}
